package com.hydl.power.service.impl;


import com.hydl.power.mapper.*;
import com.hydl.power.pojo.*;
import com.hydl.power.service.StandingBookService;
import com.hydl.power.utils.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Service
public class StandingBookServiceImpl implements StandingBookService {

    @Autowired
    private HighVoltageDistributionCabinetMapper highVoltageDistributionCabinetMapper;  //高压柜

    @Autowired
    private VacuumCircuitBreakerMapper vacuumCircuitBreakerMapper;  //高压真空断路器

    @Autowired
    private CurrentTransformerMapper currentTransformerMapper; //高压电流互感器

    @Autowired
    private MicrocomputerProtectionMapper microcomputerProtectionMapper;  //高压微机保护

    @Autowired
    private ArresterMapper arresterMapper;  //高压避雷器


    @Autowired
    private LowTensionDistributionCabinetMapper lowTensionDistributionCabinetMapper;  //低压柜

    @Autowired
    private UniversalCircuitBreakerMapper universalCircuitBreakerMapper;   //低压万能式断路器

    @Autowired
    private CapacitanceMapper capacitanceMapper;   //低压电容

    @Autowired
    private CircuitMapper circuitMapper;  //低压回路

    @Autowired
    private LowVoltageTransformerMapper lowVoltageTransformerMapper;  //低压电流互感器

    @Autowired
    private LowVoltageCircuitBreakerMapper lowVoltageCircuitBreakerMapper;   //低压断路器

    @Autowired
    private DirectCurrentScreenMapper directCurrentScreenMapper;  //直流屏

    @Autowired
    private TransformerMapper transformerMapper;  //变压器

    @Autowired
    private BatteryMapper batteryMapper;  //蓄电池

    @Autowired
    private ChargerModuleMapper chargerModuleMapper;  //充电模块

    @Autowired
    private DeviceMapper deviceMapper;




    /**
     * 查询高压柜下面的配电柜(高压柜)
     * @param projectId
     * @param powerRoomId
     * @return
     */
    @Override
    public List<HighVoltageDistributionCabinet> getHighVoltageDistributionCabinet(String projectId, String powerRoomId) {
        return highVoltageDistributionCabinetMapper.getHighVoltageDistributionCabinet(projectId,powerRoomId);
    }


    /**
     * 查询配电柜的设备数量(高压柜)
     * @param cabinetId
     * @param projectId
     * @param powerRoomId
     * @return
     */
    @Override
    public List<CabinetDevice> getHighVoltageDistributionCabinetDeviceNumber(String cabinetId, String projectId, String powerRoomId) {
        List<CabinetDevice> list=new ArrayList<>();
        CabinetDevice cabinetDevice=null;
        cabinetDevice=vacuumCircuitBreakerMapper.getCabinetDeviceNumber(cabinetId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }
        cabinetDevice=currentTransformerMapper.getCabinetDeviceNumber(cabinetId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }
        cabinetDevice=microcomputerProtectionMapper.getCabinetDeviceNumber(cabinetId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }
        cabinetDevice=arresterMapper.getCabinetDeviceNumber(cabinetId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }
        return list;
    }

    /**
     * 查询设备详细信息(高压柜)
     * @param cabinetId
     * @param ldentify
     * @return
     */
    @Override
    public List getHighVoltageDistributionCabinetDevice(String cabinetId, Integer ldentify) {
        if (ldentify==1){
            List<VacuumCircuitBreaker> list=vacuumCircuitBreakerMapper.getDeviceList(cabinetId);
            return list;
        }else if(ldentify==2){
            List<CurrentTransformer> list=currentTransformerMapper.getDeviceList(cabinetId);
            return list;
        }else if(ldentify==3){
            List<MicrocomputerProtection> list=microcomputerProtectionMapper.getDeviceList(cabinetId);
            return list;
        }else if(ldentify==4){
            List<Arrester> list=arresterMapper.getDeviceList(cabinetId);
            return list;
        }
        return null;
    }

    /**
     * 查询低压柜下面的配电柜(低压柜)
     * @param projectId
     * @param powerRoomId
     * @return
     */
    @Override
    public List<LowTensionDistributionCabinet> getLowTensionDistributionCabinet(String projectId, String powerRoomId) {
        List<LowTensionDistributionCabinet> list= lowTensionDistributionCabinetMapper.getLowTensionDistributionCabinet(projectId,powerRoomId);
        return list;
    }




    /**
     * 查询配电柜的设备数量(低压柜)
     * @param cabinetId
     * @param projectId
     * @param powerRoomId
     * @return
     */
    @Override
    public List<CabinetDevice> getLowTensionDistributionCabinetDeviceNumber(String cabinetId, String projectId, String powerRoomId) {
        List<CabinetDevice> list=new ArrayList<>();
        CabinetDevice cabinetDevice=null;
        cabinetDevice = universalCircuitBreakerMapper.getCabinetDeviceNumber(cabinetId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }
        cabinetDevice = capacitanceMapper.getCabinetDeviceNumber(cabinetId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }
        cabinetDevice = circuitMapper.getCabinetDeviceNumber(cabinetId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }

        return list;

    }


    /**
     * 查询设备详细信息(低压柜)
     * @param cabinetId
     * @param ldentify
     * @return
     */
    @Override
    public List getLowTensionDistributionCabinetDevice(String cabinetId, Integer ldentify) {
        if (ldentify==5){
            List<UniversalCircuitBreaker> list = universalCircuitBreakerMapper.getDeviceList(cabinetId);
            return list;
        }else if(ldentify==6){
            List<Capacitance> list = capacitanceMapper.getDeviceList(cabinetId);
            return list;
        }else if(ldentify==7){
            List<Circuit> list = circuitMapper.getDeviceList(cabinetId);
            for (Circuit circuit:list){
                LowVoltageTransformer lowVoltageTransformer = lowVoltageTransformerMapper.getDeviceByCircuitId(circuit.getCircuitId());
                LowVoltageCircuitBreaker lowVoltageCircuitBreaker = lowVoltageCircuitBreakerMapper.getDeviceByCircuitId(circuit.getCircuitId());
                circuit.setLowVoltageCircuitBreaker(lowVoltageCircuitBreaker);
                circuit.setLowVoltageTransformer(lowVoltageTransformer);
            }
            return list;
        }
        return null;
    }


    /**
     * 查询回路设备详细信息(低压柜)
     * @param circuitId
     * @return
     */
    @Override
    public List getCircuitDevice(String circuitId) {
        List list = new ArrayList();

        LowVoltageTransformer lowVoltageTransformer = lowVoltageTransformerMapper.getDeviceByCircuitId(circuitId);
        if (lowVoltageTransformer!=null){
            list.add(lowVoltageTransformer);
        }
        LowVoltageCircuitBreaker lowVoltageCircuitBreaker = lowVoltageCircuitBreakerMapper.getDeviceByCircuitId(circuitId);
        if (lowVoltageCircuitBreaker!=null){
            list.add(lowVoltageCircuitBreaker);
        }

        return list;
    }

    /**
     * 添加高压柜的配电柜(高压柜)
     * @param name
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addHighVoltageDistributionCabinet(String name, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        HighVoltageDistributionCabinet highVoltageDistributionCabinet=new HighVoltageDistributionCabinet();
        highVoltageDistributionCabinet.setCabinetId(IdUtil.getRandomString(8));
        highVoltageDistributionCabinet.setName(name);
        highVoltageDistributionCabinet.setProjectId(projectId);
        highVoltageDistributionCabinet.setProjectName(projectName);
        highVoltageDistributionCabinet.setPowerRoomId(powerRoomId);
        highVoltageDistributionCabinet.setPowerRoomName(powerRoomName);
        highVoltageDistributionCabinet.setImgUrl("http://1.192.214.12:8086/peijianwang/进线柜.png");
        highVoltageDistributionCabinetMapper.addHighVoltageDistributionCabinet(highVoltageDistributionCabinet);
    }

    /**
     * 修改高压柜的配电柜
     * @param cabinetId
     * @param name
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateHighVoltageDistributionCabinet(String cabinetId, String name, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        highVoltageDistributionCabinetMapper.updateHighVoltageDistributionCabinet(cabinetId,name,projectId,projectName,powerRoomId,powerRoomName);
    }


    /**
     * 删除高压柜的配电柜
     * @param cabinetId
     */
    @Override
    public Integer deleteHighVoltageDistributionCabinet(String cabinetId) {
        List<VacuumCircuitBreaker> vacuumCircuitBreakerList = vacuumCircuitBreakerMapper.getDeviceList(cabinetId);
        List<CurrentTransformer> currentTransformerList = currentTransformerMapper.getDeviceList(cabinetId);
        List<MicrocomputerProtection> microcomputerProtectionList = microcomputerProtectionMapper.getDeviceList(cabinetId);
        List<Arrester> arresterList = arresterMapper.getDeviceList(cabinetId);
        if (vacuumCircuitBreakerList.size()>0 || currentTransformerList.size()>0 || microcomputerProtectionList.size()>0 || arresterList.size()>0){
            return 0;
        }
        highVoltageDistributionCabinetMapper.deleteHighVoltageDistributionCabinet(cabinetId);
        return 1;
    }


    /**
     * 添加真空断路器
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param frequency
     * @param voltage
     * @param electricCurrent
     * @param controlVoltage
     * @param energyStorageVoltage
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addVacuumCircuitBreaker(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String frequency, String voltage, String electricCurrent, String controlVoltage, String energyStorageVoltage, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        VacuumCircuitBreaker vacuumCircuitBreaker=new VacuumCircuitBreaker();
        vacuumCircuitBreaker.setCabinetId(cabinetId);
        vacuumCircuitBreaker.setName(name);
        vacuumCircuitBreaker.setControlVoltage(controlVoltage);
        vacuumCircuitBreaker.setDeviceName("真空断路器");
        vacuumCircuitBreaker.setLdentify("1");
        vacuumCircuitBreaker.setElectricCurrent(electricCurrent);
        vacuumCircuitBreaker.setEnergyStorageVoltage(energyStorageVoltage);
        vacuumCircuitBreaker.setFrequency(frequency);
        vacuumCircuitBreaker.setSerialNumber(serialNumber);
        vacuumCircuitBreaker.setModelNumber(modelNumber);
        vacuumCircuitBreaker.setVoltage(voltage);
        vacuumCircuitBreaker.setManufactor(manufactor);
        vacuumCircuitBreaker.setProductionTime(productionTime);
        vacuumCircuitBreaker.setProjectId(projectId);
        vacuumCircuitBreaker.setProjectName(projectName);
        vacuumCircuitBreaker.setPowerRoomId(powerRoomId);
        vacuumCircuitBreaker.setPowerRoomName(powerRoomName);
        vacuumCircuitBreaker.setImgUrl("http://1.192.214.12:8086/peijianwang/10KV高压真空断路器.png");
        vacuumCircuitBreakerMapper.addVacuumCircuitBreaker(vacuumCircuitBreaker);
    }

    /**
     * 修改真空断路器
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param frequency
     * @param voltage
     * @param electricCurrent
     * @param controlVoltage
     * @param energyStorageVoltage
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateVacuumCircuitBreaker(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String frequency, String voltage, String electricCurrent, String controlVoltage, String energyStorageVoltage, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        vacuumCircuitBreakerMapper.updateVacuumCircuitBreaker(id,name,manufactor,serialNumber,modelNumber,productionTime,frequency,voltage,electricCurrent,controlVoltage,energyStorageVoltage,cabinetId,projectId,projectName,powerRoomId,powerRoomName);
    }


    /**
     * 删除真空断路器
     * @param id
     */
    @Override
    public void deleteVacuumCircuitBreaker(Integer id) {
        vacuumCircuitBreakerMapper.deleteVacuumCircuitBreaker(id);
    }


    /**
     * 添加高压柜电流互感器
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param transformationRatio
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addCurrentTransformer(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String transformationRatio, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        CurrentTransformer currentTransformer=new CurrentTransformer();
        currentTransformer.setName(name);
        currentTransformer.setManufactor(manufactor);
        currentTransformer.setSerialNumber(serialNumber);
        currentTransformer.setModelNumber(modelNumber);
        currentTransformer.setProductionTime(productionTime);
        currentTransformer.setTransformationRatio(transformationRatio);
        currentTransformer.setCabinetId(cabinetId);
        currentTransformer.setProjectId(projectId);
        currentTransformer.setProjectName(projectName);
        currentTransformer.setPowerRoomId(powerRoomId);
        currentTransformer.setPowerRoomName(powerRoomName);
        currentTransformer.setLdentify("2");
        currentTransformer.setDeviceName("电流互感器");
        currentTransformer.setImgUrl("http://1.192.214.12:8086/peijianwang/电流互感器.png");
        currentTransformerMapper.addCurrentTransformer(currentTransformer);
    }

    /**
     * 修改高压柜电流互感器
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param transformationRatio
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateCurrentTransformer(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String transformationRatio, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        currentTransformerMapper.updateCurrentTransformer(id,name,manufactor,serialNumber,modelNumber,productionTime,transformationRatio,cabinetId,projectId,projectName,powerRoomId,powerRoomName);
    }


    /**
     * 删除高压柜电流互感器
     * @param id
     */
    @Override
    public void deleteCurrentTransformer(Integer id) {
        currentTransformerMapper.deleteCurrentTransformer(id);
    }

    /**
     * 添加高压柜微机保护
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addMicrocomputerProtection(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        MicrocomputerProtection microcomputerProtection=new MicrocomputerProtection();
        microcomputerProtection.setName(name);
        microcomputerProtection.setManufactor(manufactor);
        microcomputerProtection.setSerialNumber(serialNumber);
        microcomputerProtection.setModelNumber(modelNumber);
        microcomputerProtection.setProductionTime(productionTime);
        microcomputerProtection.setCabinetId(cabinetId);
        microcomputerProtection.setProjectId(projectId);
        microcomputerProtection.setProjectName(projectName);
        microcomputerProtection.setPowerRoomId(powerRoomId);
        microcomputerProtection.setPowerRoomName(powerRoomName);
        microcomputerProtection.setLdentify("3");
        microcomputerProtection.setDeviceName("微机保护");
        microcomputerProtection.setImgUrl("http://1.192.214.12:8086/peijianwang/综保.png");
        microcomputerProtectionMapper.addMicrocomputerProtection(microcomputerProtection);
    }

    /**
     * 修改高压柜微机保护
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateMicrocomputerProtection(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        microcomputerProtectionMapper.updateMicrocomputerProtection(id,name,manufactor,serialNumber,modelNumber,productionTime,cabinetId,projectId,projectName,powerRoomId,powerRoomName);
    }


    /**
     * 删除高压柜微机保护
     * @param id
     */
    @Override
    public void deleteMicrocomputerProtection(Integer id) {
        microcomputerProtectionMapper.deleteMicrocomputerProtection(id);
    }

    /**
     * 添加高压柜避雷器
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addArrester(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        Arrester arrester=new Arrester();
        arrester.setName(name);
        arrester.setManufactor(manufactor);
        arrester.setSerialNumber(serialNumber);
        arrester.setModelNumber(modelNumber);
        arrester.setProductionTime(productionTime);
        arrester.setCabinetId(cabinetId);
        arrester.setProjectId(projectId);
        arrester.setProjectName(projectName);
        arrester.setPowerRoomId(powerRoomId);
        arrester.setPowerRoomName(powerRoomName);
        arrester.setLdentify("4");
        arrester.setDeviceName("避雷器");
        arrester.setImgUrl("http://1.192.214.12:8086/peijianwang/避雷器.png");
        arresterMapper.addArrester(arrester);
    }


    /**
     * 修改高压柜避雷器
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateArrester(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        arresterMapper.updateArrester(id,name,manufactor,serialNumber,modelNumber,productionTime,cabinetId,projectId,projectName,powerRoomId,powerRoomName);
    }


    /**
     * 删除高压柜避雷器
     * @param id
     */
    @Override
    public void deleteArrester(Integer id) {
        arresterMapper.deleteArrester(id);
    }

    /**
     *添加低压柜的配电柜
     * @param name
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addLowTensionDistributionCabinet(String name, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        LowTensionDistributionCabinet lowTensionDistributionCabinet=new LowTensionDistributionCabinet();
        lowTensionDistributionCabinet.setCabinetId(IdUtil.getRandomString(8));
        lowTensionDistributionCabinet.setName(name);
        lowTensionDistributionCabinet.setProjectId(projectId);
        lowTensionDistributionCabinet.setProjectName(projectName);
        lowTensionDistributionCabinet.setPowerRoomId(powerRoomId);
        lowTensionDistributionCabinet.setPowerRoomName(powerRoomName);
        lowTensionDistributionCabinet.setImgUrl("http://1.192.214.12:8086/peijianwang/馈线柜.png");
        lowTensionDistributionCabinetMapper.addLowTensionDistributionCabinet(lowTensionDistributionCabinet);
    }


    /**
     * 修改低压柜的配电柜
     * @param cabinetId
     * @param name
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateLowTensionDistributionCabinet(String cabinetId, String name, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        lowTensionDistributionCabinetMapper.updateLowTensionDistributionCabinet(cabinetId,name,projectId,projectName,powerRoomId,powerRoomName);
    }


    /**
     * 删除低压柜的配电柜
     * @param cabinetId
     */
    @Override
    public Integer deleteLowTensionDistributionCabinet(String cabinetId) {
        List<UniversalCircuitBreaker> universalCircuitBreakerList = universalCircuitBreakerMapper.getDeviceList(cabinetId);
        List<Capacitance> capacitanceList = capacitanceMapper.getDeviceList(cabinetId);
        List<Circuit> circuitList = circuitMapper.getDeviceList(cabinetId);
        if (universalCircuitBreakerList.size()>0 || capacitanceList.size()>0 || circuitList.size()>0){
            return 0;
        }
        lowTensionDistributionCabinetMapper.deleteLowTensionDistributionCabinet(cabinetId);
        return 1;
    }


    /**
     * 添加低压柜万能式断路器
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param ue
     * @param lcu
     * @param ln
     */
    @Override
    public void addUniversalCircuitBreaker(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName, String ue, String lcu, String ln) {
        UniversalCircuitBreaker universalCircuitBreaker=new UniversalCircuitBreaker();
        universalCircuitBreaker.setName(name);
        universalCircuitBreaker.setManufactor(manufactor);
        universalCircuitBreaker.setSerialNumber(serialNumber);
        universalCircuitBreaker.setModelNumber(modelNumber);
        universalCircuitBreaker.setProductionTime(productionTime);
        universalCircuitBreaker.setCabinetId(cabinetId);
        universalCircuitBreaker.setProjectId(projectId);
        universalCircuitBreaker.setProjectName(projectName);
        universalCircuitBreaker.setPowerRoomId(powerRoomId);
        universalCircuitBreaker.setPowerRoomName(powerRoomName);
        universalCircuitBreaker.setUe(ue);
        universalCircuitBreaker.setLcu(lcu);
        universalCircuitBreaker.setLn(ln);
        universalCircuitBreaker.setLdentify("5");
        universalCircuitBreaker.setDeviceName("万能式断路器");
        universalCircuitBreaker.setImgUrl("http://1.192.214.12:8086/peijianwang/低压断路器.png");
        universalCircuitBreakerMapper.addUniversalCircuitBreaker(universalCircuitBreaker);
    }


    /**
     * 修改低压柜万能式断路器
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param ue
     * @param lcu
     * @param ln
     */
    @Override
    public void updateUniversalCircuitBreaker(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName, String ue, String lcu, String ln) {
        universalCircuitBreakerMapper.updateUniversalCircuitBreaker(id,name,manufactor,serialNumber,modelNumber,productionTime,cabinetId,projectId,projectName,powerRoomId,powerRoomName,ue,lcu,ln);
    }


    /**
     * 删除低压柜万能式断路器
     * @param id
     */
    @Override
    public void deleteUniversalCircuitBreaker(Integer id) {
        universalCircuitBreakerMapper.deleteUniversalCircuitBreaker(id);
    }


    /**
     * 添加低压柜电容
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param ratedCapacity
     * @param ratedCapacitance
     * @param ratedVoltage
     * @param ratedCurrent
     */
    @Override
    public void addCapacitance(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName, String ratedCapacity, String ratedCapacitance, String ratedVoltage, String ratedCurrent) {
        Capacitance capacitance=new Capacitance();
        capacitance.setName(name);
        capacitance.setManufactor(manufactor);
        capacitance.setSerialNumber(serialNumber);
        capacitance.setModelNumber(modelNumber);
        capacitance.setProductionTime(productionTime);
        capacitance.setCabinetId(cabinetId);
        capacitance.setProjectId(projectId);
        capacitance.setProjectName(projectName);
        capacitance.setPowerRoomId(powerRoomId);
        capacitance.setPowerRoomName(powerRoomName);
        capacitance.setRatedCapacity(ratedCapacity);
        capacitance.setRatedCapacitance(ratedCapacitance);
        capacitance.setRatedVoltage(ratedVoltage);
        capacitance.setRatedCurrent(ratedCurrent);
        capacitance.setLdentify("6");
        capacitance.setDeviceName("电容");
        capacitance.setImgUrl("http://1.192.214.12:8086/peijianwang/电容器.png");
        capacitanceMapper.addCapacitance(capacitance);
    }

    /**
     * 修改低压柜电容
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param ratedCapacity
     * @param ratedCapacitance
     * @param ratedVoltage
     * @param ratedCurrent
     */
    @Override
    public void updateCapacitance(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName, String ratedCapacity, String ratedCapacitance, String ratedVoltage, String ratedCurrent) {
        capacitanceMapper.updateCapacitance(id,name,manufactor,serialNumber,modelNumber,productionTime,cabinetId,projectId,projectName,powerRoomId,powerRoomName,ratedCapacity,ratedCapacitance,ratedVoltage,ratedCurrent);
    }


    /**
     * 删除低压柜电容
     * @param id
     */
    @Override
    public void deleteCapacitance(Integer id) {
        capacitanceMapper.deleteCapacitance(id);
    }


    /**
     * 添加低压柜回路
     * @param name
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addCircuit(String name,  String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        Circuit circuit=new Circuit();
        circuit.setName(name);
        circuit.setCircuitId(IdUtil.getRandomString(8));
        circuit.setCabinetId(cabinetId);
        circuit.setProjectId(projectId);
        circuit.setProjectName(projectName);
        circuit.setPowerRoomId(powerRoomId);
        circuit.setPowerRoomName(powerRoomName);
        circuit.setLdentify("7");
        circuit.setDeviceName("回路");
        circuit.setImgUrl("http://1.192.214.12:8086/peijianwang/回路.png");
        circuitMapper.addCircuit(circuit);
    }


    /**
     * 修改低压柜回路
     * @param id
     * @param name
     * @param cabinetId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateCircuit(Integer id, String name, String cabinetId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        circuitMapper.updateCircuit(id,name,cabinetId,projectId,projectName,powerRoomId,powerRoomName);
    }


    /**
     * 删除低压柜回路
     * @param id
     */
    @Override
    public Integer deleteCircuit(Integer id) {
        Circuit circuit = circuitMapper.getCircuitById(id);
        LowVoltageTransformer lowVoltageTransformer = lowVoltageTransformerMapper.getDeviceByCircuitId(circuit.getCircuitId());
        LowVoltageCircuitBreaker lowVoltageCircuitBreaker = lowVoltageCircuitBreakerMapper.getDeviceByCircuitId(circuit.getCircuitId());
        if (lowVoltageTransformer!=null || lowVoltageCircuitBreaker!=null){
            return 0;
        }
        circuitMapper.deleteCircuit(id);
        return 1;
    }


    /**
     * 添加低压柜电流互感器
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param transformationRatio
     * @param circuitId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addLowVoltageTransformer(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String transformationRatio, String circuitId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        LowVoltageTransformer lowVoltageTransformer=new LowVoltageTransformer();
        lowVoltageTransformer.setName(name);
        lowVoltageTransformer.setManufactor(manufactor);
        lowVoltageTransformer.setSerialNumber(serialNumber);
        lowVoltageTransformer.setModelNumber(modelNumber);
        lowVoltageTransformer.setProductionTime(productionTime);
        lowVoltageTransformer.setTransformationRatio(transformationRatio);
        lowVoltageTransformer.setCircuitId(circuitId);
        lowVoltageTransformer.setProjectId(projectId);
        lowVoltageTransformer.setProjectName(projectName);
        lowVoltageTransformer.setPowerRoomId(powerRoomId);
        lowVoltageTransformer.setPowerRoomName(powerRoomName);
        lowVoltageTransformer.setDeviceName("电流互感器");
        lowVoltageTransformer.setLdentify("8");
        lowVoltageTransformer.setImgUrl("http://1.192.214.12:8086/peijianwang/电流互感器.png");
        lowVoltageTransformerMapper.addLowVoltageTransformer(lowVoltageTransformer);
    }


    /**
     * 修改低压柜电流互感器
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param transformationRatio
     * @param circuitId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateLowVoltageTransformer(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String transformationRatio, String circuitId, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        lowVoltageTransformerMapper.updateLowVoltageTransformer(id,name,manufactor,serialNumber,modelNumber,productionTime,transformationRatio,circuitId,projectId,projectName,powerRoomId,powerRoomName);
    }


    /**
     * 删除低压柜电流互感器
     * @param id
     */
    @Override
    public void deleteLowVoltageTransformer(Integer id) {
        lowVoltageTransformerMapper.deleteLowVoltageTransformer(id);
    }


    /**
     * 添加回路断路器
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param circuitId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param ue
     * @param lcu
     * @param ln
     */
    @Override
    public void addLowVoltageCircuitBreaker(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String circuitId, String projectId, String projectName, String powerRoomId, String powerRoomName, String ue, String lcu, String ln) {
        LowVoltageCircuitBreaker lowVoltageCircuitBreaker=new LowVoltageCircuitBreaker();
        lowVoltageCircuitBreaker.setName(name);
        lowVoltageCircuitBreaker.setManufactor(manufactor);
        lowVoltageCircuitBreaker.setSerialNumber(serialNumber);
        lowVoltageCircuitBreaker.setModelNumber(modelNumber);
        lowVoltageCircuitBreaker.setProductionTime(productionTime);
        lowVoltageCircuitBreaker.setCircuitId(circuitId);
        lowVoltageCircuitBreaker.setProjectId(projectId);
        lowVoltageCircuitBreaker.setProjectName(projectName);
        lowVoltageCircuitBreaker.setPowerRoomId(powerRoomId);
        lowVoltageCircuitBreaker.setPowerRoomName(powerRoomName);
        lowVoltageCircuitBreaker.setUe(ue);
        lowVoltageCircuitBreaker.setLcu(lcu);
        lowVoltageCircuitBreaker.setLn(ln);
        lowVoltageCircuitBreaker.setLdentify("9");
        lowVoltageCircuitBreaker.setDeviceName("断路器");
        lowVoltageCircuitBreaker.setImgUrl("http://1.192.214.12:8086/peijianwang/低压断路器.png");
        lowVoltageCircuitBreakerMapper.addLowVoltageCircuitBreaker(lowVoltageCircuitBreaker);
    }


    /**
     * 修改回路断路器
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param circuitId
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param ue
     * @param lcu
     * @param ln
     */
    @Override
    public void updateLowVoltageCircuitBreaker(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String circuitId, String projectId, String projectName, String powerRoomId, String powerRoomName, String ue, String lcu, String ln) {
        lowVoltageCircuitBreakerMapper.updateLowVoltageCircuitBreaker(id,name,manufactor,serialNumber,modelNumber,productionTime,circuitId,projectId,projectName,powerRoomId,powerRoomName,ue,lcu,ln);
    }


    /**
     * 删除回路断路器
     * @param id
     */
    @Override
    public void deleteLowVoltageCircuitBreaker(Integer id) {
        lowVoltageCircuitBreakerMapper.deleteLowVoltageCircuitBreaker(id);
    }


    /**
     * 根据配电柜id查询回路
     * @param cabinetId
     * @return
     */
    @Override
    public List<Circuit> getCircuit(String cabinetId) {
        return  circuitMapper.getCircuitByCabinetId(cabinetId);
    }


    /**
     * 查询直流屏
     * @param projectId
     * @param powerRoomId
     * @return
     */
    @Override
    public List<DirectCurrentScreen> getDirectCurrentScreenDevice(String projectId, String powerRoomId) {
        return  directCurrentScreenMapper.getDirectCurrentScreenDevice(projectId,powerRoomId);
    }

    /**
     * 查询变压器
     * @param projectId
     * @param powerRoomId
     * @return
     */
    @Override
    public List<Transformer> getTransformerDevice(String projectId, String powerRoomId) {
        return transformerMapper.getTransformerDevice(projectId,powerRoomId);
    }


    /**
     * 查询直流屏充电模块
     * @param directCurrentScreenId
     * @return
     */
    @Override
    public List<ChargerModule> getChargerModule(String directCurrentScreenId) {
        return chargerModuleMapper.getChargerModule(directCurrentScreenId);
    }


    /**
     * 查询直流屏蓄电池
     * @param directCurrentScreenId
     * @return
     */
    @Override
    public List<Battery> getBattery(String directCurrentScreenId) {
        return batteryMapper.getBattery(directCurrentScreenId);
    }

    @Override
    public List<CabinetDevice> getDirectCurrentScreenDeviceNumber(String directCurrentScreenId, String projectId, String powerRoomId) {
        List<CabinetDevice> list=new ArrayList<>();
        CabinetDevice cabinetDevice=null;
        cabinetDevice = chargerModuleMapper.getDirectCurrentScreenDeviceNumber(directCurrentScreenId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }
        cabinetDevice = batteryMapper.getDirectCurrentScreenDeviceNumber(directCurrentScreenId,projectId,powerRoomId);
        if (cabinetDevice.getDeviceNumber()>0){
            list.add(cabinetDevice);
        }


        return list;
    }


    /**
     * 添加直流屏
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param projectId
     *  @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void addDirectCurrentScreen(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        DirectCurrentScreen directCurrentScreen=new DirectCurrentScreen();
        directCurrentScreen.setName(name);
        directCurrentScreen.setManufactor(manufactor);
        directCurrentScreen.setSerialNumber(serialNumber);
        directCurrentScreen.setModelNumber(modelNumber);
        directCurrentScreen.setProductionTime(productionTime);
        directCurrentScreen.setProjectId(projectId);
        directCurrentScreen.setProjectName(projectName);
        directCurrentScreen.setPowerRoomId(powerRoomId);
        directCurrentScreen.setPowerRoomName(powerRoomName);
        directCurrentScreen.setDeviceName("直流屏");
        directCurrentScreen.setImgUrl("http://1.192.214.12:8086/peijianwang/直流屏.jpg");
        directCurrentScreenMapper.addDirectCurrentScreen(directCurrentScreen);
    }

    /**
     *  修改直流屏
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     */
    @Override
    public void updateDirectCurrentScreen(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String projectId, String projectName, String powerRoomId, String powerRoomName) {
        directCurrentScreenMapper.updateDirectCurrentScreen(id,name,manufactor,serialNumber,modelNumber,productionTime,projectId,projectName,powerRoomId,powerRoomName);
    }

    /**
     * 删除直流屏
     * @param id
     */
    @Override
    public Integer deleteDirectCurrentScreen(Integer id) {
        List<ChargerModule> chargerModuleList = chargerModuleMapper.getChargerModule(id.toString());
        List<Battery> batteryList = batteryMapper.getBattery(id.toString());
        if (chargerModuleList.size()>0 || batteryList.size()>0){
            return 0;
        }
        directCurrentScreenMapper.deleteDirectCurrentScreen(id);
        return 1;
    }


    /**
     * 添加充电模块
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param directCurrentScreenId
     */
    @Override
    public void addChargerModule(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String projectId, String projectName, String powerRoomId, String powerRoomName, String directCurrentScreenId) {
        ChargerModule chargerModule=new ChargerModule();
        chargerModule.setName(name);
        chargerModule.setManufactor(manufactor);
        chargerModule.setSerialNumber(serialNumber);
        chargerModule.setModelNumber(modelNumber);
        chargerModule.setProductionTime(productionTime);
        chargerModule.setProjectId(projectId);
        chargerModule.setProjectName(projectName);
        chargerModule.setPowerRoomId(powerRoomId);
        chargerModule.setPowerRoomName(powerRoomName);
        chargerModule.setDirectCurrentScreenId(directCurrentScreenId);
        chargerModule.setDeviceName("充电模块");
        chargerModule.setLdentify("11");
        chargerModule.setImgUrl("http://1.192.214.12:8086/peijianwang/充电模块.png");
        chargerModuleMapper.addChargerModule(chargerModule);
    }


    /**
     * 修改充电模块
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param directCurrentScreenId
     */
    @Override
    public void updateChargerModule(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String projectId, String projectName, String powerRoomId, String powerRoomName, String directCurrentScreenId) {
        chargerModuleMapper.updateChargerModule(id,name,manufactor,serialNumber,modelNumber,productionTime,projectId,projectName,powerRoomId,powerRoomName,directCurrentScreenId);
    }


    /**
     * 删除充电模块
     * @param id
     */
    @Override
    public void deleteChargerModule(Integer id) {
        chargerModuleMapper.deleteChargerModule(id);
    }


    /**
     * 添加蓄电池
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param directCurrentScreenId
     * @param deviceNumber
     */
    @Override
    public void addBattery(String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String projectId, String projectName, String powerRoomId, String powerRoomName, String directCurrentScreenId, String deviceNumber) {
        Battery battery=new Battery();
        battery.setName(name);
        battery.setManufactor(manufactor);
        battery.setSerialNumber(serialNumber);
        battery.setModelNumber(modelNumber);
        battery.setProductionTime(productionTime);
        battery.setProjectId(projectId);
        battery.setProjectName(projectName);
        battery.setPowerRoomId(powerRoomId);
        battery.setPowerRoomName(powerRoomName);
        battery.setDirectCurrentScreenId(directCurrentScreenId);
        battery.setDeviceName("蓄电池");
        battery.setLdentify("10");
        battery.setDeviceNumber(deviceNumber);
        battery.setImgUrl("http://1.192.214.12:8086/peijianwang/电池.png");
        batteryMapper.addBattery(battery);
    }


    /**
     * 修改蓄电池
     * @param id
     * @param name
     * @param manufactor
     * @param serialNumber
     * @param modelNumber
     * @param productionTime
     * @param projectId
     * @param projectName
     * @param powerRoomId
     * @param powerRoomName
     * @param directCurrentScreenId
     * @param deviceNumber
     */
    @Override
    public void updateBattery(Integer id, String name, String manufactor, String serialNumber, String modelNumber, String productionTime, String projectId, String projectName, String powerRoomId, String powerRoomName, String directCurrentScreenId, String deviceNumber) {
        batteryMapper.updateBattery(id,name,manufactor,serialNumber,modelNumber,productionTime,projectId,projectName,powerRoomId,powerRoomName,directCurrentScreenId,deviceNumber);
    }


    /**
     * 删除蓄电池
     * @param id
     */
    @Override
    public void deleteBattery(Integer id) {
        batteryMapper.deleteBattery(id);
    }

    @Override
    public void addTransformer(String transformerName, String transformerCapacity, String manufactor, String modelNumber, String productionTime, String cityId, String cityName, String projectId, String projectName, String powerRoomId, String powerRoomName, String deviceId, String deviceName, String installTime) {
        Transformer transformer=new Transformer();
        transformer.setTransformerName(transformerName);
        transformer.setTransformerCapacity(transformerCapacity);
        transformer.setManufactor(manufactor);
        transformer.setModelNumber(modelNumber);
        transformer.setProductionTime(productionTime);
        transformer.setCityId(cityId);
        transformer.setCityName(cityName);
        transformer.setProjectId(projectId);
        transformer.setProjectName(projectName);
        transformer.setRoomId(powerRoomId);
        transformer.setRoomName(powerRoomName);
        transformer.setInstallTime(installTime);
        transformer.setDeviceId(deviceId);
        transformer.setDeviceName(deviceName);
        transformerMapper.addTransformer(transformer);
    }

    @Override
    public void updateTransformer(Integer id, String transformerName, String transformerCapacity, String manufactor, String modelNumber, String productionTime, String cityId, String cityName, String projectId, String projectName, String powerRoomId, String powerRoomName, String deviceId, String deviceName, String installTime) {
        transformerMapper.updateTransformer(id,transformerName,transformerCapacity,manufactor,modelNumber,productionTime,cityId,cityName,projectId,projectName,powerRoomId,powerRoomName,deviceId,deviceName,installTime);
    }

    @Override
    public void deleteTransformer(Integer id) {
        transformerMapper.deleteById(id);
    }

    @Override
    public List<Device> getDevice(String powerRoomId) {
        List<Device> list = deviceMapper.getDeviceByPowerRoomId(powerRoomId);
        return list;
    }


}
